<?php
declare (strict_types=1);

namespace app\listener;

use app\common\model\Knowledge;

class KnowledgeRead
{
    /**
     * 文章详情读取 事件监听处理
     *
     * @return mixed
     */
    public function handle($params)
    {
        $knowledgeId = $params['knowledgeId'] ?? null;

        if (!is_id($knowledgeId)) {
            return;
        }

        Knowledge::where('id', $knowledgeId)
            ->inc('readNum', 1)
            ->update();
    }
}
